import java.util.Scanner;

/**
 * @Author @fiber-cloud
 * @Date 2025/6/15 11:30
 */
public class Test {
    //数字统计
    public static void main(String[] args) {
//        Scanner sc = new Scanner(System.in);
//        int a = sc.nextInt();
//        int b = sc.nextInt();
//
//        int count = 0;
//        for (int i = a; i <= b ; i++) {
//            int tmp = i;
//            while (tmp != 0){
//                if (tmp % 10 == 2) {
//                    count ++;
//                }
//                tmp /= 10;
//            }
//        }
//        System.out.println(count);

        hanio(1,'A','B','C');
        System.out.println();
        hanio(2,'A','B','C');
        System.out.println();
        hanio(4,'A','B','C');
    }
    //汉诺塔
    /*
    1: A -> C   1次   2^1 -1
    2: A -> B A -> C B -> C  3次   2^2 -1
    3: A -> C A -> B C -> B A -> C B -> A B -> C A -> C 7次   2^3 -1
     */
    public static void hanio(int n,char pos1,char pos2,char pos3){
        if (n == 1){
            move(pos1,pos3);
            return;
        }
        hanio(n-1 ,pos1,pos3,pos2);
        move(pos1,pos3);
        hanio(n-1,pos2,pos1,pos3);
    }

    public static void move(char pos1,char pos2){
        System.out.print(pos1+" -> "+pos2+" ");
    }
}
